﻿using System;
using System.Data.SqlClient;
using System.Windows.Forms;

namespace Elkomp {

	public partial class Form1 : FormaBrowse {
		SqlConnection con = new SqlConnection();
		SqlCommand com = new SqlCommand();
		SqlDataAdapter Adapter;

		public Form1() {
			InitializeComponent();
			con.ConnectionString = MainConnection;
			com.Connection = con;
			com.CommandText = this.SelectSql;
			Db.Tables.Clear();
			Db.Tables.Add( this.UpdateTable );
			Adapter = new SqlDataAdapter( com );
		}

		private void Form1_Load( object sender, EventArgs e ) {
			Adapter.Fill( Db.Tables[this.UpdateTable] );
			bs.DataSource = Db.Tables[this.UpdateTable];
			Navigator.BindingSource = bs;
			grid1.DataSource = bs;
		}

		public override void NovZapis( object sender, EventArgs e ) {
			grid1.Insert();
			base.NovZapis( sender, e );
		}

		public override void IzmeniZapis( object sender, EventArgs e ) {
			grid1.Edit();
			base.IzmeniZapis( sender, e );
		}

		private void grid1_CellMouseDoubleClick( object sender, DataGridViewCellMouseEventArgs e ) {
			grid1.Edit();
		}
	}
}